<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改密码</title>
<link rel="stylesheet" href="${ctx }/resources/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="${ctx }/resources/css/public.css" media="all" />
<link rel="stylesheet" href="${ctx }/resources/zTree/css/metroStyle/metroStyle.css" type="text/css">
<link rel="stylesheet" type="text/css" href="${ctx }/resources/plugin/css/index.css">
</head>
<body class="childrenBody">
	<form class="layui-form" action="#" id="frm" method="post" lay-filter="frm">
		<div class="layui-input-block layui-red pwdTips">旧密码请输入“123456”，新密码必须两次输入一致才能提交</div>
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="hidden" name="id" value="${user.id }">
				<input type="text" value="${user.loginname }" disabled class="layui-input layui-disabled">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码</label>
			<div class="layui-input-block">
				<input type="password" name="oldPwd" id="oldPwd" placeholder="请输入旧密码" lay-verify="required|pwd" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-block">
				<input type="password" name="newpwd1" id="newpwd1" placeholder="请输入新密码" lay-verify="required|newpwd1" class="layui-input pwd">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-block">
				<input type="password" name="newpwd2" id="newpwd2" placeholder="请确认密码" lay-verify="required|newpwd2" class="layui-input pwd">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block" style="text-align: center;">
				<!--lay-submit标记当按钮是一个提交按钮   -->
				<a href="javascript:void(0)" class="layui-btn" lay-submit=""  lay-filter="userSubmit">提交</a>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript" src="${ctx }/resources/layui/layui.js"></script>
<script type="text/javascript" src="${ctx }/resources/zTree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx }/resources/zTree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${ctx }/resources/plugin/js/selectTree.js"></script>
<script type="text/javascript">
var form;
layui.use([ 'form','jquery','layer','laydate' ], function() {
	form=layui.form;//得到form对象
	var $=layui.jquery;
	var laydate=layui.laydate;
	var layer = parent.layer === undefined ? layui.layer : parent.layer;
	
	//表单验证

	form.verify({

		newpwd1: [/(.+){6,12}$/, '密码必须6到12位'],

		newpwd2: function(value) {

			if(value != $("#newpwd1").val()){
		
				$("#newpwd2").val("");
			
				return '两次密码不一致';
		
			}
			
			form.on("submit(userSubmit)",function(data){
				var params=$("#frm").serialize();
				$.post("${ctx}/user/updatePwd.action?"+params,function(obj){
					//console.log(params);
					layer.msg(obj.msg);
					parent.tableIns.reload();//刷新表格
					//关闭窗口
					var index=layer.getFrameIndex(window.name);
					layer.close(index);
				}) 
			});

		},
	});	
	
	//添加提交事件
	/* form.on("submit(userSubmit)",function(data){
		var params=$("#frm").serialize();
		$.post("${ctx}/user/updatePwd.action?"+params,function(obj){
			//console.log(params);
			layer.msg(obj.msg);
			parent.tableIns.reload();//刷新表格
			//关闭窗口
			var index=layer.getFrameIndex(window.name);
			layer.close(index);
		}) 
	}); */
});	


</script>
</html>